<?php


namespace app\backend\controller;


use app\base\controller\AdminBaseController;
use think\facade\Request;

class Config extends AdminBaseController
{
    public function index(){

        $list = \app\common\model\Config::where(['is_edit'=>1])->all();

        $this->assign('list',$list);
        return $this->fetch();
    }


    public function save(){
        $post = Request::post();

        $info = new \app\common\model\Config();
        foreach ($post['id'] as $k=>$v){
            $details = $info->where(['id'=>$v])->find();
            if($details == null){
                $details = $info;
            }
            $details->config_name = $post['config_name'][$k];
            $details->config_value = $post['config_value'][$k];
            $details->config_key = $post['config_key'][$k];
            $details->save();
        }
        wapAjaxReturn(0,'操作成功');
    }

}